package org.xtb.BS.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.xtb.BS.dao.ContactsDao;
import org.xtb.BS.service.ContactsService;
import org.xtb.pojo.Contacts;

import java.util.List;

@Service
public class ContactsServiceImpl implements ContactsService {
    @Autowired
    private ContactsDao contactsDao;
    @Override
    public List<Contacts> getAll() {
        return contactsDao.queryAll();
    }

    @Override
    public Boolean addOne(Contacts contacts) {
        return contactsDao.insertOne
                (contacts.getName(),contacts.getAddress(), contacts.getPhone())==1;
    }

    @Override
    public Boolean deleteOne(Contacts contacts) {
        return contactsDao.deleteOne(contacts.getId())==1;
    }

    @Override
    public Boolean updateOne(Contacts contacts) {
        return contactsDao.updateOne
                (contacts.getName(),contacts.getAddress(),
                        contacts.getPhone(),contacts.getId())==1;
    }
}
